/* ----------------------------------------------------------------------
*
* Copyright (C) 2024 XiaoFei. All rights reserved.
*
* @file:		XiaoZhi_Key.c
* @author:		XiaoFei
* @Date:     	29-March-2024
* @Revision: 	V1
* @Project: 	XiaoFei BSP Library
*
* -------------------------------------------------------------------- */

#include "stm32f4xx.h"
#include "XiaoFei_Delay.h"
#include "XiaoZhi_Key.h"

/* 
* @function: 	GPIO_Key_Init
*/
void GPIO_Key_Init(void)				
{
    Key_RCC(1);		
	GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin=Key_Pin;
	GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN; 		
    GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;	
    GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
    GPIO_Init(Key_GPIO,&GPIO_InitStructure);
}
	
/* 
* @function: 	Key_Get
* @return:		Return 0x01 when the key is set.
*/
unsigned char Key_Get(void)
{
	if(Key_Rd==Key_EN)
	{
		XiaoFei_Delay_ms(20);
		while(Key_Rd==Key_EN);
		XiaoFei_Delay_ms(20);
		return 0x01;
	}
	return 0x00;
}


